package com.bupt.ilink.service.bailian.impl;

import com.aliyun.bailian20231229.models.AddCategoryResponse;
import com.aliyun.tea.TeaException;
import com.bupt.ilink.service.bailian.AddCategoryService;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
public class AddCategoryServiceImpl implements AddCategoryService {

/**
 * 返回格式
 *{
 *   "Status": "200",
 *   "Message": "",
 *   "RequestId": "40A4A0F9-CAC4-5468-AA2D-A03FC404C8F2",
 *   "Data": {
 *     "CategoryId": "cate_37ca0f29c90342f2971e8bd549b7b394_10249160",
 *     "CategoryName": "test2"
 *   },
 *   "Code": "Success",
 *   "Success": true
 * }
 **/
    @Override
    public AddCategoryResponse addCategory(com.aliyun.bailian20231229.Client client, String WorkspaceId, String CategoryName, String CategoryType) throws Exception {
        com.aliyun.bailian20231229.models.AddCategoryRequest addCategoryRequest = new com.aliyun.bailian20231229.models.AddCategoryRequest()
                .setCategoryName(CategoryName)
                .setCategoryType(CategoryType);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            return client.addCategoryWithOptions(WorkspaceId, addCategoryRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new TeaException(error.getMessage(), error);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new Exception(error.getMessage());
        }
    }

    @Override
    public AddCategoryResponse addCategory(com.aliyun.bailian20231229.Client client, String WorkspaceId, String CategoryName, String CategoryType, String parentCategoryId) throws Exception {
        com.aliyun.bailian20231229.models.AddCategoryRequest addCategoryRequest = new com.aliyun.bailian20231229.models.AddCategoryRequest()
                .setCategoryName(CategoryName)
                .setCategoryType(CategoryType)
                .setParentCategoryId(parentCategoryId);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            return client.addCategoryWithOptions(WorkspaceId, addCategoryRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new TeaException(error.getMessage(), error);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new Exception(error.getMessage());
        }
    }
}
